﻿namespace ExamV5.ManagSys
{
    using ExamV5;
    using System;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;

    public class FrmSendInfo : Page
    {
        protected Button butClose;
        protected Button butDefault;
        protected HtmlForm Form1;
        private HttpCookie httpCookie_0 = null;
        private HttpCookie httpCookie_1 = null;
        private HttpCookie httpCookie_2 = null;
        private HttpCookie httpCookie_3 = null;
        protected Label labLength;
        private PublicFun publicFun_0 = new PublicFun();
        protected ScriptManager SM;
        protected TextBox txtSendDoc;
        protected UpdatePanel UPPart;

        protected void butDefault_Click(object sender, EventArgs e)
        {
            if (this.ViewState["UserPower"].ToString() == "Y")
            {
                string str = "";
                str = base.Request.Form["txtBrowUserCode"].ToString();
                base.Request.Form["txtBrowUserName"].ToString();
                if (str == "")
                {
                    ScriptManager.RegisterStartupScript(this.UPPart, this.Page.GetType(), "BInput", "alert('请选择人员信息！')", true);
                }
                else if (!(this.txtSendDoc.Text.Trim() == "") ? (this.txtSendDoc.Text.Trim().Length <= 70) : false)
                {
                    string[] strArray = str.Split(new char[] { ',' });
                    for (int i = 0; i < strArray.Length; i++)
                    {
                        if (strArray[i].Trim() != "")
                        {
                            this.publicFun_0.SendHandSet(strArray[i].Trim(), this.txtSendDoc.Text.Trim(), this.httpCookie_1.Value, this.httpCookie_0.Value);
                        }
                    }
                    ScriptManager.RegisterStartupScript(this.UPPart, this.Page.GetType(), "BSucc", "alert('发送手机短信操作成功！');window.close();", true);
                }
                else
                {
                    ScriptManager.RegisterStartupScript(this.UPPart, this.Page.GetType(), "BInput", "alert('短信内容不可以为空并在70个汉字以内！')", true);
                }
            }
            else
            {
                ScriptManager.RegisterStartupScript(this.UPPart, this.Page.GetType(), "BPower", "alert('用户管理权限未开放！')", true);
            }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            this.httpCookie_0 = new HttpCookie("ExamUserCode");
            this.httpCookie_0 = base.Request.Cookies["ExamUserCode"];
            this.httpCookie_1 = new HttpCookie("ExamUserName");
            this.httpCookie_1 = base.Request.Cookies["ExamUserName"];
            this.httpCookie_2 = new HttpCookie("ExamUserLevel");
            this.httpCookie_2 = base.Request.Cookies["ExamUserLevel"];
            this.httpCookie_3 = new HttpCookie("ExamDeptID");
            this.httpCookie_3 = base.Request.Cookies["ExamDeptID"];
            if (!((this.httpCookie_0 != null) ? !(this.httpCookie_0.Value == "") : false))
            {
                base.Response.Write("<script language=javascript>top.location.href='../Index.htm';self.close();</script>");
            }
            else
            {
                base.Response.Cache.SetCacheability(HttpCacheability.NoCache);
                base.Response.Cache.SetNoStore();
                this.httpCookie_0.Value = this.publicFun_0.CheckString(base.Server.UrlDecode(this.httpCookie_0.Value));
                this.httpCookie_1.Value = this.publicFun_0.CheckString(base.Server.UrlDecode(this.httpCookie_1.Value));
                this.httpCookie_2.Value = this.publicFun_0.CheckString(base.Server.UrlDecode(this.httpCookie_2.Value));
                this.httpCookie_3.Value = this.publicFun_0.CheckString(base.Server.UrlDecode(this.httpCookie_3.Value));
                if (!base.IsPostBack)
                {
                    this.ViewState["UserPower"] = this.publicFun_0.GetValues("select ManagUser from UserPower where UserCode='" + this.httpCookie_0.Value + "'", "ManagUser");
                }
            }
        }
    }
}

